﻿var p = 0;
var q = false;
$(function () {
    for (var i = 0; i < d.length; i++) {
        $('#datas').append('<li><div class="aui-car-box-list-item"><div class="aui-car-box-list-img"><a href="/shop/product_dtl?code=' + d[i].pcode + '"><img src="' + d[i].ppic + '"></a></div><div class="aui-car-box-list-text"><h4><a href="ui-product.html">' + d[i].pname + ' ' + d[i].psubname + '</a></h4><div class="aui-car-box-list-text-brief"><span>规格：' + d[i].g[d[i].gg - 1].name + '</span></div><div class="aui-car-box-list-text-brief"><span>库存情况：' + (d[i].g[d[i].gg - 1].n == 1 ? '有货' : '<span style="color:#f00;">缺货!</span>') + '</span></div><div class="aui-car-box-list-text-price"><div class="aui-car-box-list-text-pri">￥<b class="price">' + (d[i].pprice * d[i].num).toFixed(2) + '</b></div><div class="aui-car-box-list-text-arithmetic"><a href="javascript:;" class="minus" onclick="reducew(' + i + ')">-</a><span class="num">' + d[i].num + '</span><a href="javascript:;" class="plus" onclick="plusw(' + i + ')">+</a></div></div></div></div></li>');
        if (d[i].g[d[i].gg - 1].n != 1) {
            q = true;
        }
        p += d[i].pprice * d[i].num;
    }
    $('#AllTotal').html(p.toFixed(2));
});
function reducew(n) {
    if (d[n].num <= 1) {
        layer.open({
            content: '确认删除？'
    , btn: ['删除', '取消']
    , skin: 'footer'
    , yes: function (index) {
        loading();
        $.post('/dos_m/shop_cart_upgrade_del', { code: d[n].code, x: x }, function (d) { eval(d); });
    }
        });
    }
    else {
        loading();
        $.post('/dos_m/shop_cart_upgrade_reducew', { code: d[n].code, x: x }, function (d) { eval(d); });
    }
}
function plusw(n) {
    loading();
    $.post('/dos_m/shop_cart_upgrade_plusw', { code: d[n].code, x: x }, function (d) { eval(d); });
}
function ok() {
    location.href = location.href;
}
function subs() {

    location.href = '/shop/add_upgrade_order?x=' + x + '&price_start=' + price_start;
}